#include<stdio.h>
#include<stdlib.h>

#define maxLength 20

//  实现带加减乘除的多项式运算
typedef struct StackInt{
    int StackPoint;
    int Stack[maxLength];
}stackint;

typedef struct StackSign{
    int StackPoint;
    char Stack[maxLength];
}stacksign;


//
int juadgeNum(char ch)
{
    if (ch>='0' && ch<='9')
    {
        return 1;
    }
    return 0;
}

//堆栈的实现
void Intpush(stackint* stack,int index)
{
    if (stack->StackPoint>=maxLength)
    {
        printf("堆栈已满");
    }
    stack->Stack[++(stack->StackPoint)]=index;
    
}

//
int Intpop(stackint* stack)
{
    if (stack->StackPoint!=-1)
    {
        return stack->Stack[stack->StackPoint--];
    }
    return -1;
    
}

void charpush(stacksign* stack,char index)
{
    if (stack->StackPoint>=maxLength)
    {
        printf("堆栈已满");
    }
    stack->Stack[++(stack->StackPoint)]=index;  
}

//
char charpop(stacksign* stack)
{
    if (stack->StackPoint!=-1)
    {
        return stack->Stack[stack->StackPoint--];
    }
    return -1;
    
}
void charToNum(stackint* stack,int* intcounts)
{
    int accumulation=0;
    int index=0;
    int count=0;
    while (intcounts[index]!=-1)
    {
        count=count*10+intcounts[index++];
    }
    Intpush(stack,count);
    
    
}
int judgeSigned(char ch1,char ch2)
{

    
    if(ch1==ch2)
    {
        return 1;
    }
    if (ch1=='*' && ch2=='/')
    {
        return 1;
    }
    if ((ch1=='*'||ch1=='/')&&(ch2=='+'||ch2=='-'))
    {
        return 1;
    }
    if ((ch1=='+'||ch1=='-')&&(ch2=='*'||ch2=='/'))
    {
        return 0;
    }
    
    return 1;
    
}
void countValue(stackint* stack,int before,int after,char ch)
{
    int result;
    switch(ch){
        case '+':result=before+after;break;
        case '-':result=before-after;break;
        case '*':result=before*after;break;
        case '/':result=before/after;break;
    }
    Intpush(stack,result);
}
//表达式的最终计算
int finallyCount(stackint* stack,stacksign* signs)
{
    int before;
    int after;
    int ch;
    while (signs->StackPoint!=-1)
    {
        after=Intpop(stack);
        before=Intpop(stack);
        ch=charpop(signs);
        if (ch=='-')
        {
            after=-after;
            ch='+';
        }
        
        countValue(stack,before,after,ch);
    }
    return stack->Stack[0];
    
}
void main()
{
    char chs[20];
    char qw[20];
    char signch[10];
    int ins[10];
    char ch;
    int judgeI=1;
    stackint Numbers;
    Numbers.StackPoint=-1;
    stacksign Signs;
    Signs.StackPoint=-1;
    scanf("%s",chs);
    printf("%s\n",chs);
    int i=0;
    int Intcounts[8];
    int countindex=0;
    while(chs[i]!='\0')
    {
        ch=chs[i++];
        printf("%c\n",ch);
        if (juadgeNum(ch))
        {
            Intcounts[countindex++]=(ch-48);
            Intcounts[countindex]=-1;
            // Intpush(&Numbers,ch-48);
        }
        else
        {
            if (judgeI==1)
            {
                charToNum(&Numbers,Intcounts);
                countindex=0;
            }


            if(judgeSigned(ch,Signs.Stack[Signs.StackPoint])||Signs.StackPoint==-1)
            {
                charpush(&Signs,ch);
                judgeI=1;
            }
            else{
                //分别出栈计算表达式
                countValue(&Numbers,Intpop(&Numbers),Intpop(&Numbers),charpop(&Signs));
                i--;
                Signs.Stack[Signs.StackPoint+1]='#';
                judgeI=0;
            }

        }
    }
    charToNum(&Numbers,Intcounts);
    countindex=0;

    int cou=finallyCount(&Numbers,&Signs);
    printf("\n%d\n",cou);
    // printf("\n");
    // while (Signs.StackPoint!=-1)
    // {
    //     printf("%c ",charpop(&Signs));
    // }
    // while (Numbers.StackPoint!=-1)
    // {
    //     printf("%d ",Intpop(&Numbers));
    // }
}